//自定义封装函数
import { ref } from 'vue'
export const userList = (Listapi, parmes) => {
	const list = ref([]);
	const nothing = ref(true);
	const getList = async () => {
		const { data } = await Listapi(parmes);
		console.log('通知列表', data);
		list.value.push(...data.items || []);
		if (+data.counts === list.value.length) {
			nothing.value = false;
		}
	};
	getList()
	//上拉触底加载更多
	const goButton = async () => {
		console.log('触底了');
		if (nothing.value === false) return;
		parmes.page++;
		await getList();
	};
	const isTriggered = ref(false);
	// 下拉刷新
	const Refresh = async () => {
		isTriggered.value = true; //开启下拉刷新
		parmes.page = 1;
		list.value = [];
		nothing.value = true;
		await getList();
		isTriggered.value = false; // 刷新完成时 关闭 loading 效果
	};
	return { getList, goButton, Refresh, list, isTriggered }
}